#ifndef _H_COMMLIBSERVER
#define _H_COMMLIBSERVER

#include "Comm.h"

class Server
{
	std::vector<Connection*> m_clients;
	
	//CRITICAL_SECTION criticalSection;
	SOCKET m_listenSocket;
	HANDLE m_hListenThread;
	bool m_listening;
	static DWORD WINAPI ListenThread(void* lpParam);
	addrinfo* m_pAddressInfo;

public:
	Server();
	~Server();
	bool Initalize();
	bool Release();
	
	bool BeginListenForClients();
	bool EndListenForClients();

	bool SendDataPacket(void* pData, unsigned int sizeInBytes, int packetID, unsigned int clientID);
	bool GetDataPackets(std::vector<Connection::Packet> *pDataPacketList, unsigned int clientID);
	bool CheckForClient(unsigned int clientID);
	unsigned int ClientCount();

	bool Update();
};

#endif